Sleep Demands
Sleep Demands
A sleep demand informs a routine that the Power Manager is about to put
the Macintosh Portable into the sleep state. When a routine in the sleep queue
receives a sleep demand, it must prepare for the sleep state as quickly as
possible and return control to the Power Manager.
The following figure illustrates the sequence of events that occurs when the
Power Manager issues a sleep demand.
How the sleep queue handles a sleep demand
From the point of view of the Power Manager, there are two types of sleep
demands-conditional and unconditional. The Power Manager might cancel a
conditional sleep demand if certain network services are in use; an
unconditional sleep demand cannot be canceled. When your sleep queue routine
receives a sleep demand, however, your routine has no way to determine
whether it originated as a conditional sleep demand or an unconditional sleep
demand. Your device driver or application must prepare for the sleep state
and return control promptly to the Power Manager when it receives a sleep
demand.
The Power Manager processes a conditional sleep demand when the user
chooses Sleep from the Battery desk accessory or from the Special menu in the
Finder. When the Power Manager processes a conditional sleep demand, it
first sends a sleep request to the network driver's sleep queue routine.
Whenever one of the network services is in use, the sleep queue routine
displays a dialog box requesting the user's permission to put the Macintosh
Portable into the sleep state. The wording of the message in the dialog box
depends on the nature of the network service in use. For example, if an .XPP
driver protocol is in use, has opened a server, and has mounted a volume, then
the message warns the user that the volume will be closed when the Macintosh
Portable is put into the sleep state.
If the user denies permission to close the driver, the Power Manager does
not send sleep demands to the routines in the sleep queue. If the user does give
permission to close the driver, the Power Manager sends a sleep demand to
the network driver's sleep queue routine and then to every other routine in the
sleep queue.
The Power Manager issues an unconditional sleep demand when the battery
voltage falls below a preset level or when the user chooses Shut Down from the
Special menu in the Finder. In this case, the Power Manager sends a sleep
demand to the network driver's sleep queue entry, which closes all network
drivers. Then the Power Manager sends a sleep demand to every other
routine in the sleep queue. As always for a sleep demand, each routine must
prepare for the sleep state and return control to the Power Manager as
quickly as possible. In this case, the Power Manager does not display any
warnings or dialog boxes; neither the network services, the user, nor any
application can deny the sleep demand.